package com.infolab.aims.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.list.LazyList;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.validator.constraints.NotBlank;

import com.infolab.aims.common.bean.AbstractModelBean;

@Entity
@Table(name="AMTB_SYSTEM_CODE_TYPE")
public class SystemCodeType extends AbstractModelBean implements Serializable {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer systemCodeTypeId;
	
	@NotBlank(message="{error.empty}")
	private String systemCodeTypeCode;
	
	private String systemCodeTypeValue;
	
	@NotBlank(message="{error.empty}")
	private String systemCodeTypeDescription;
	
	@ManyToOne
	@JoinColumn(name="accessDepartmentId")
	private Department accessDepartment;
	
	@Column(columnDefinition="number(1,0) default 1 not null")
	private boolean active;
	
	private boolean multiple;
	
	@OneToMany(mappedBy="systemCodeType")
	@OrderBy("systemCode1 ASC")
	private List<SystemCodeValue> systemCodeValues;
	
	@Transient
	private List<SystemCodeValue> systemCodeValuesForm = LazyList.decorate(new ArrayList(),
		      FactoryUtils.instantiateFactory(SystemCodeValue.class));

	public Integer getSystemCodeTypeId() {
		return systemCodeTypeId;
	}

	public void setSystemCodeTypeId(Integer systemCodeTypeId) {
		this.systemCodeTypeId = systemCodeTypeId;
	}

	public String getSystemCodeTypeValue() {
		return systemCodeTypeValue;
	}

	public void setSystemCodeTypeValue(String systemCodeTypeValue) {
		this.systemCodeTypeValue = systemCodeTypeValue;
	}

	public String getSystemCodeTypeDescription() {
		return systemCodeTypeDescription;
	}

	public void setSystemCodeTypeDescription(String systemCodeTypeDescription) {
		this.systemCodeTypeDescription = systemCodeTypeDescription;
	}

	public Department getAccessDepartment() {
		return accessDepartment;
	}

	public void setAccessDepartment(Department accessDepartment) {
		this.accessDepartment = accessDepartment;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getSystemCodeTypeCode() {
		return systemCodeTypeCode;
	}

	public void setSystemCodeTypeCode(String systemCodeTypeCode) {
		this.systemCodeTypeCode = systemCodeTypeCode;
	}

	public List<SystemCodeValue> getSystemCodeValues() {
		return systemCodeValues;
	}

	public void setSystemCodeValues(List<SystemCodeValue> systemCodeValues) {
		this.systemCodeValues = systemCodeValues;
	}

	public List<SystemCodeValue> getSystemCodeValuesForm() {
		return systemCodeValuesForm;
	}

	public void setSystemCodeValuesForm(List<SystemCodeValue> systemCodeValuesForm) {
		this.systemCodeValuesForm = systemCodeValuesForm;
	}

	public boolean isMultiple() {
		return multiple;
	}

	public void setMultiple(boolean multiple) {
		this.multiple = multiple;
	}
	public String getAuditContentHead()
	{
				
		return new ToStringBuilder(this,ToStringStyle.SHORT_PREFIX_STYLE)
			.append("Code",systemCodeTypeCode)
			.append("Value",systemCodeTypeValue)
			.append("Desc",systemCodeTypeDescription)
			.toString();
	}
	
	public String getAuditContentDetail()
	{
		return "Not Applicable";
	}
}
